<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8">
    <meta name="description" content="Linux磁盘管理"/>
    <meta name="keywords"
          content="nginx,freebsd,linux,mysql,shell,apache,centos,redhat,rhel,windows,sql,系统运维,IT运维,开源系统,开源系统运维"/>
    <title> Linux磁盘管理 </title>

</head>
<body bgcolor="#FFFFFF" text="#000000">
<div id="menu">
    <ul>
		<span style="FONT-SIZE: 10.5pt">

			<li><a href="index.htm" hidefocus="true" id="mn_list">linux入门教程</a></li>

		</span>
    </ul>
</div>
<p style="text-align: center;"><span style="font-family:'宋体';font-size:15pt;"><b>第八章</b></span><span
        style="font-family:'Calibri';font-size:15pt;"><b>  Linux</b></span><span
        style="font-family:'宋体';font-size:15pt;"><b>磁盘管理</b></span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">	</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">【</span><span
        style="font-family:'宋体';font-size:10.5pt;"><b>查看磁盘或者目录的容量</b></span><span
        style="font-family:'Calibri';font-size:10.5pt;"><b> df </b></span><span
        style="font-family:'宋体';font-size:10.5pt;"><b>和</b></span><span style="font-family:'Calibri';font-size:10.5pt;"><b> du</b></span><span
        style="font-family:'Calibri';font-size:10.5pt;">】</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">	</span><span
        style="font-family:'Calibri';font-size:10.5pt;"><b>df </b></span><span
        style="font-family:'Calibri';font-size:10.5pt;"> </span><span style="font-family:'宋体';font-size:10.5pt;">查看已挂载磁盘的总容量</span><span
        style="font-family:'Calibri';font-size:10.5pt;">、</span><span
        style="font-family:'宋体';font-size:10.5pt;">使用容量</span><span
        style="font-family:'Calibri';font-size:10.5pt;">、</span><span style="font-family:'宋体';font-size:10.5pt;">剩余容量等，可以不加任何参数，默认是按</span><span
        style="font-family:'Calibri';font-size:10.5pt;">k</span><span
        style="font-family:'宋体';font-size:10.5pt;">为单位显示的</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;"><img src="8_1.png"></span></p>


<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">	df</span><span
        style="font-family:'宋体';font-size:10.5pt;">常用参数有</span><span style="font-family:'Calibri';font-size:10.5pt;"> –i  -h  -k  –m</span><span
        style="font-family:'宋体';font-size:10.5pt;">等</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">	-i  </span><span
        style="font-family:'宋体';font-size:10.5pt;">使用</span><span
        style="font-family:'Calibri';font-size:10.5pt;">inodes </span><span style="font-family:'宋体';font-size:10.5pt;">显示结果</span>
</p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;"><img src="8_12.png"></span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">	-h  </span><span
        style="font-family:'宋体';font-size:10.5pt;">使用合适的单位显示，例如</span><span
        style="font-family:'Calibri';font-size:10.5pt;">G</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;"><img src="8_13.png"></span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">	-k  -m </span><span
        style="font-family:'宋体';font-size:10.5pt;">分别为使用</span><span
        style="font-family:'Calibri';font-size:10.5pt;">K</span><span
        style="font-family:'宋体';font-size:10.5pt;">，</span><span
        style="font-family:'Calibri';font-size:10.5pt;">M</span><span
        style="font-family:'宋体';font-size:10.5pt;">为单位显示</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;"><img src="8_14.png"></span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">	</span><span
        style="font-family:'宋体';font-size:10.5pt;">简单介绍一下，你看到的相关数据</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。Filesystem </span><span
        style="font-family:'宋体';font-size:10.5pt;">表示扇区，也就是你划分磁盘时所分的区；</span><span
        style="font-family:'Calibri';font-size:10.5pt;">1K-blocks/1M-blocks</span><span
        style="font-family:'宋体';font-size:10.5pt;">表示以</span><span
        style="font-family:'Calibri';font-size:10.5pt;">1K/1M</span><span style="font-family:'宋体';font-size:10.5pt;">为单位；</span><span
        style="font-family:'Calibri';font-size:10.5pt;">Used </span><span
        style="font-family:'宋体';font-size:10.5pt;">和</span><span style="font-family:'Calibri';font-size:10.5pt;"> Available </span><span
        style="font-family:'宋体';font-size:10.5pt;">分别是已使用和剩余；</span><span
        style="font-family:'Calibri';font-size:10.5pt;">Use% </span><span style="font-family:'宋体';font-size:10.5pt;">就是已经使用的百分比，如果这个值大于</span><span
        style="font-family:'Calibri';font-size:10.5pt;">90% </span><span style="font-family:'宋体';font-size:10.5pt;">那么你就应该注意了，磁盘很有可能马上就会变满的；</span><span
        style="font-family:'Calibri';font-size:10.5pt;">Mounted on </span><span
        style="font-family:'宋体';font-size:10.5pt;">则表示该分区（扇区）所挂载的地方</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">	</span><span
        style="font-family:'Calibri';font-size:10.5pt;"><b>du  </b></span><span
        style="font-family:'宋体';font-size:10.5pt;"><b>用来查看某个目录所占空间大小</b></span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">	</span><span
        style="font-family:'宋体';font-size:10.5pt;">语法：</span><span style="font-family:'Calibri';font-size:10.5pt;">du [-abckmsh]  [</span><span
        style="font-family:'宋体';font-size:10.5pt;">文件或者目录名</span><span
        style="font-family:'Calibri';font-size:10.5pt;">]  </span><span style="font-family:'宋体';font-size:10.5pt;">常用的参数有：</span>
</p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">	-a</span><span
        style="font-family:'宋体';font-size:10.5pt;">：全部文件与目录大小都列出来</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span style="font-family:'宋体';font-size:10.5pt;">如果不加任何选项和参数只列出目录（包含子目录）大小</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;"><img src="8_15.png"></span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">	-b</span><span
        style="font-family:'宋体';font-size:10.5pt;">：列出的值以</span><span style="font-family:'Calibri';font-size:10.5pt;">bytes</span><span
        style="font-family:'宋体';font-size:10.5pt;">为单位输出，默认是以</span><span
        style="font-family:'Calibri';font-size:10.5pt;">Kbytes</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;"><img src="8_16.png"></span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">	-c</span><span
        style="font-family:'宋体';font-size:10.5pt;">：最后加总</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;"><img src="8_17.png"></span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">	-k</span><span
        style="font-family:'宋体';font-size:10.5pt;">：以</span><span
        style="font-family:'Calibri';font-size:10.5pt;">KB</span><span
        style="font-family:'宋体';font-size:10.5pt;">为单位输出</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">	-m</span><span
        style="font-family:'宋体';font-size:10.5pt;">：以</span><span
        style="font-family:'Calibri';font-size:10.5pt;">MB</span><span
        style="font-family:'宋体';font-size:10.5pt;">为单位输出</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">	-s</span><span
        style="font-family:'宋体';font-size:10.5pt;">：只列出总和</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">	-h</span><span
        style="font-family:'宋体';font-size:10.5pt;">：系统自动调节单位，例如文件太小可能就几</span><span
        style="font-family:'Calibri';font-size:10.5pt;">K</span><span
        style="font-family:'宋体';font-size:10.5pt;">，那么就以</span><span
        style="font-family:'Calibri';font-size:10.5pt;">K</span><span style="font-family:'宋体';font-size:10.5pt;">为单位显示，如果大到几</span><span
        style="font-family:'Calibri';font-size:10.5pt;">G</span><span
        style="font-family:'宋体';font-size:10.5pt;">，则就以</span><span
        style="font-family:'Calibri';font-size:10.5pt;">G</span><span
        style="font-family:'宋体';font-size:10.5pt;">为单位显示</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span
        style="font-family:'宋体';font-size:10.5pt;">笔者习惯用</span><span style="font-family:'Calibri';font-size:10.5pt;">  du –sh  filename  </span><span
        style="font-family:'宋体';font-size:10.5pt;">这样的形式</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;"><img src="8_18.png"></span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;"><b>【</b></span><span
        style="font-family:'宋体';font-size:10.5pt;"><b>磁盘的分区和格式化</b></span><span
        style="font-family:'Calibri';font-size:10.5pt;"><b>】</b></span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">	</span><span
        style="font-family:'宋体';font-size:10.5pt;">笔者经常做的事情就是拿一个全新的磁盘来分区并格式化</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span style="font-family:'宋体';font-size:10.5pt;">这也说明了作为一个</span><span
        style="font-family:'Calibri';font-size:10.5pt;">linux</span><span style="font-family:'宋体';font-size:10.5pt;">系统管理员，对于磁盘的操作必须要熟练</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span style="font-family:'宋体';font-size:10.5pt;">所以请你认真学习该部分内容</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">	fdisk  linux</span><span
        style="font-family:'宋体';font-size:10.5pt;">下的硬盘分区工具</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">	</span><span
        style="font-family:'宋体';font-size:10.5pt;">语法：</span><span style="font-family:'Calibri';font-size:10.5pt;"> fdisk  [-l ] [</span><span
        style="font-family:'宋体';font-size:10.5pt;">设备名称</span><span
        style="font-family:'Calibri';font-size:10.5pt;">]</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">	-l </span><span
        style="font-family:'宋体';font-size:10.5pt;">：后边不跟设备名会直接列出系统中所有的磁盘设备以及分区表，加上设备名会列出该设备的分区表</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;"><img src="8_19.png"></span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;"><img src="8_20.png"></span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">	</span><span
        style="font-family:'宋体';font-size:10.5pt;">如果不加</span><span
        style="font-family:'Calibri';font-size:10.5pt;">-l </span><span style="font-family:'宋体';font-size:10.5pt;">则进入另一个模式，在该模式下，可以对磁盘进行分区操作</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;"><img src="8_21.png"></span></p>
<p style="text-align: justify;"><span style="font-family:'宋体';font-size:10.5pt;">刚进入该模式下，会有一个提示</span><span
        style="font-family:'Calibri';font-size:10.5pt;">Command (m for help): </span><span
        style="font-family:'宋体';font-size:10.5pt;">此时按</span><span
        style="font-family:'Calibri';font-size:10.5pt;">m</span><span style="font-family:'宋体';font-size:10.5pt;">则会打印出帮助列表，如果你英文好，我想你不难理解这些字母的功能</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span
        style="font-family:'宋体';font-size:10.5pt;">笔者常用的有</span><span style="font-family:'Calibri';font-size:10.5pt;">p, n,d, w, q. </span>
</p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">	P</span><span
        style="font-family:'宋体';font-size:10.5pt;">：打印当前磁盘的分区情况</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;"><img src="8_29.png"></span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">	n</span><span
        style="font-family:'宋体';font-size:10.5pt;">：重新建立一个新的分区</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">	w</span><span
        style="font-family:'宋体';font-size:10.5pt;">：保存操作</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">	q</span><span
        style="font-family:'宋体';font-size:10.5pt;">：退出</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">	d</span><span
        style="font-family:'宋体';font-size:10.5pt;">：删除一个分区</span></p>
<p style="text-align: justify;text-indent: 21pt;"><span style="font-family:'宋体';font-size:10.5pt;">因为笔者的</span><span
        style="font-family:'Calibri';font-size:10.5pt;">linux</span><span style="font-family:'宋体';font-size:10.5pt;">系统是安装在虚拟机上的，所以我可以增加一块新的磁盘</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span style="font-family:'宋体';font-size:10.5pt;">然后笔者会把新的磁盘分成多个分区</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;"><img src="8_30.png"></span></p>
<p style="text-align: justify;"><span style="font-family:'宋体';font-size:10.5pt;">当再次</span><span
        style="font-family:'Calibri';font-size:10.5pt;">fdisk -l </span><span
        style="font-family:'宋体';font-size:10.5pt;">查看时发现多了一个</span><span
        style="font-family:'Calibri';font-size:10.5pt;">/dev/hdb </span><span
        style="font-family:'宋体';font-size:10.5pt;">设备，并提示该设备没有可用的分区表</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span style="font-family:'宋体';font-size:10.5pt;">那么下面就来分一下这个</span><span
        style="font-family:'Calibri';font-size:10.5pt;">/dev/hdb.</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;"><img src="8_31.png"></span></p>
<p style="text-align: justify;"><span style="font-family:'宋体';font-size:10.5pt;">首先用</span><span
        style="font-family:'Calibri';font-size:10.5pt;">p</span><span style="font-family:'宋体';font-size:10.5pt;">查看一下，并没有任何分区信息</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;"><img src="8_32.png"></span></p>
<p style="text-align: justify;"><span style="font-family:'宋体';font-size:10.5pt;">用</span><span
        style="font-family:'Calibri';font-size:10.5pt;">n</span><span style="font-family:'宋体';font-size:10.5pt;">创建一个新的分区，会提示要建立</span><span
        style="font-family:'Calibri';font-size:10.5pt;">e </span><span
        style="font-family:'宋体';font-size:10.5pt;">（</span><span style="font-family:'Calibri';font-size:10.5pt;">extended </span><span
        style="font-family:'宋体';font-size:10.5pt;">扩展分区）或者</span><span
        style="font-family:'Calibri';font-size:10.5pt;">p </span><span
        style="font-family:'宋体';font-size:10.5pt;">（</span><span style="font-family:'Calibri';font-size:10.5pt;">primary partition</span><span
        style="font-family:'宋体';font-size:10.5pt;">主分区），这里笔者选择主分区，所以按了</span><span
        style="font-family:'Calibri';font-size:10.5pt;">p</span><span style="font-family:'宋体';font-size:10.5pt;">回车后，又让输入</span><span
        style="font-family:'Calibri';font-size:10.5pt;">First  cylinder </span><span
        style="font-family:'宋体';font-size:10.5pt;">你或者直接回车或者输入一个数字，因为这块磁盘是新的并没有任何分区，所以直接回车其实就是从</span><span
        style="font-family:'Calibri';font-size:10.5pt;">1</span><span
        style="font-family:'宋体';font-size:10.5pt;">开始了</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span style="font-family:'宋体';font-size:10.5pt;">你也可以自定义输入，但不要超过</span><span
        style="font-family:'Calibri';font-size:10.5pt;">2080</span><span style="font-family:'宋体';font-size:10.5pt;">，笔者这里输入</span><span
        style="font-family:'Calibri';font-size:10.5pt;">1</span><span
        style="font-family:'宋体';font-size:10.5pt;">回车</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span style="font-family:'宋体';font-size:10.5pt;">此时会提示要分多大，可以写一个数值（</span><span
        style="font-family:'Calibri';font-size:10.5pt;">2-2080</span><span style="font-family:'宋体';font-size:10.5pt;">），也可以输入</span><span
        style="font-family:'Calibri';font-size:10.5pt;">+sizeK</span><span
        style="font-family:'宋体';font-size:10.5pt;">或者</span><span
        style="font-family:'Calibri';font-size:10.5pt;">+sizeM</span><span style="font-family:'宋体';font-size:10.5pt;">，后者比较直观容易理解，所以笔者在这里输入</span><span
        style="font-family:'Calibri';font-size:10.5pt;">+100M</span><span style="font-family:'宋体';font-size:10.5pt;">，即我分了一个</span><span
        style="font-family:'Calibri';font-size:10.5pt;">100M</span><span
        style="font-family:'宋体';font-size:10.5pt;">的主分区</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span
        style="font-family:'宋体';font-size:10.5pt;">再用</span><span
        style="font-family:'Calibri';font-size:10.5pt;">p</span><span style="font-family:'宋体';font-size:10.5pt;">查看时，果真多出来一个分区</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span style="font-family:'宋体';font-size:10.5pt;">然后笔者继续重复前面的操作，建立了</span><span
        style="font-family:'Calibri';font-size:10.5pt;">4</span><span
        style="font-family:'宋体';font-size:10.5pt;">个主分区</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span
        style="font-family:'宋体';font-size:10.5pt;">当笔者再次输入</span><span
        style="font-family:'Calibri';font-size:10.5pt;">n</span><span style="font-family:'宋体';font-size:10.5pt;">创建分区时，结果提示错了</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;"><img src="8_33.png"></span></p>
<p style="text-align: justify;"><span style="font-family:'宋体';font-size:10.5pt;">由此你会发现，在</span><span
        style="font-family:'Calibri';font-size:10.5pt;">linux</span><span style="font-family:'宋体';font-size:10.5pt;">中最多只能创建</span><span
        style="font-family:'Calibri';font-size:10.5pt;">4</span><span style="font-family:'宋体';font-size:10.5pt;">个主分区，那如果你想多创建几个分区如何做？很容易，在创建完第三个分区后，创建第四个分区时选择扩展分区</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;"><img src="8_34.png">先删除第四个主分区，然后建立一个扩展分区</span>
</p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;"><img src="8_35.png"></span></p>
<p style="text-align: justify;"><span style="font-family:'宋体';font-size:10.5pt;">在建立扩展分区时，会问你要分多少给这个扩展分区，笔者直接回车，即把所有空间都分给了这个扩展分区</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span
        style="font-family:'宋体';font-size:10.5pt;">这个扩展分区</span><span style="font-family:'Calibri';font-size:10.5pt;">/dev/hdb4</span><span
        style="font-family:'宋体';font-size:10.5pt;">并不能往里写数据，它只是一个空壳子，需要我们继续在这个空壳中继续创建分区</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;"><img src="8_83.png"></span></p>
<p style="text-align: justify;"><span style="font-family:'宋体';font-size:10.5pt;">当建立完扩展分区，然后按</span><span
        style="font-family:'Calibri';font-size:10.5pt;">n</span><span style="font-family:'宋体';font-size:10.5pt;">创建新分区时你会发现不再提示是要建立</span><span
        style="font-family:'Calibri';font-size:10.5pt;">p</span><span
        style="font-family:'宋体';font-size:10.5pt;">还是</span><span
        style="font-family:'Calibri';font-size:10.5pt;">e</span><span style="font-family:'宋体';font-size:10.5pt;">了，因为我们已经不能再创建</span><span
        style="font-family:'Calibri';font-size:10.5pt;">p</span><span
        style="font-family:'宋体';font-size:10.5pt;">了</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span style="font-family:'宋体';font-size:10.5pt;">在这里需要你明白的是，</span><span
        style="font-family:'Calibri';font-size:10.5pt;">hdb5 </span><span style="font-family:'宋体';font-size:10.5pt;">其实只是</span><span
        style="font-family:'Calibri';font-size:10.5pt;"> hdb4 </span><span style="font-family:'宋体';font-size:10.5pt;">中的一个子分区，到目前为止可用的分区也才</span><span
        style="font-family:'Calibri';font-size:10.5pt;">4</span><span style="font-family:'宋体';font-size:10.5pt;">个，那笔者就再创建第</span><span
        style="font-family:'Calibri';font-size:10.5pt;">5</span><span
        style="font-family:'宋体';font-size:10.5pt;">个分区出来</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;"><img src="8_84.png"></span></p>
<p style="text-align: justify;"><span style="font-family:'宋体';font-size:10.5pt;">然后按</span><span
        style="font-family:'Calibri';font-size:10.5pt;">w</span><span style="font-family:'宋体';font-size:10.5pt;">保存，该模式自动退出，如果你不想保存分区信息直接按</span><span
        style="font-family:'Calibri';font-size:10.5pt;">q</span><span
        style="font-family:'宋体';font-size:10.5pt;">即可退出</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;"><img src="8_85.png"></span></p>
<p style="text-align: justify;"><span style="font-family:'宋体';font-size:10.5pt;">下面我们把刚分好的分区删除，重新建立分区</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span style="font-family:'宋体';font-size:10.5pt;">如何删除你还记得吧，对了就是直接按</span><span
        style="font-family:'Calibri';font-size:10.5pt;">d</span><span style="font-family:'宋体';font-size:10.5pt;">然后选择合适的数字</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span style="font-family:'宋体';font-size:10.5pt;">删除完所有分区后，这块磁盘就恢复如初了</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;"><img src="8_86.png"></span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;"><img src="8_87.png"></span></p>
<p style="text-align: justify;"><span style="font-family:'宋体';font-size:10.5pt;">第一个分区，我们就建立成扩展分区</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span
        style="font-family:'宋体';font-size:10.5pt;">并且分给它</span><span style="font-family:'Calibri';font-size:10.5pt;">200M。</span>
</p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;"><img src="8_88.png"></span></p>
<p style="text-align: justify;"><span style="font-family:'宋体';font-size:10.5pt;">当再次新建分区时，发生了变化，不再是</span><span
        style="font-family:'Calibri';font-size:10.5pt;">p</span><span
        style="font-family:'宋体';font-size:10.5pt;">或者</span><span
        style="font-family:'Calibri';font-size:10.5pt;">e</span><span
        style="font-family:'宋体';font-size:10.5pt;">了，而是</span><span
        style="font-family:'Calibri';font-size:10.5pt;">p</span><span
        style="font-family:'宋体';font-size:10.5pt;">或者</span><span
        style="font-family:'Calibri';font-size:10.5pt;">l</span><span style="font-family:'宋体';font-size:10.5pt;">（逻辑分区），这是为什么呢？在上面也提到了，一个扩展分区只是一个空壳，在扩展分区下才可以继续划分小的分区，这个小的分区其实就是逻辑分区了</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;"><img src="8_89.png"></span></p>
<p style="text-align: justify;"><span style="font-family:'宋体';font-size:10.5pt;">而且这个逻辑分区默认都是从字数</span><span
        style="font-family:'Calibri';font-size:10.5pt;">5</span><span style="font-family:'宋体';font-size:10.5pt;">开始的，因为前面的数字要么给主分区留着，要么给扩展分区留着</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span style="font-family:'宋体';font-size:10.5pt;">由此我们也可以得到，在</span><span
        style="font-family:'Calibri';font-size:10.5pt;">linux</span><span style="font-family:'宋体';font-size:10.5pt;">中最多可以创建</span><span
        style="font-family:'Calibri';font-size:10.5pt;">4</span><span style="font-family:'宋体';font-size:10.5pt;">个主分区，一旦创建</span><span
        style="font-family:'Calibri';font-size:10.5pt;">4</span><span style="font-family:'宋体';font-size:10.5pt;">个主分区后就不能增加任何分区了</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span style="font-family:'宋体';font-size:10.5pt;">另外最多也只能创建一个扩展分区</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span style="font-family:'宋体';font-size:10.5pt;">扩展分区下的逻辑分区最多可以创建多少呢？</span><span
        style="font-family:'Calibri';font-size:10.5pt;">IDE</span><span style="font-family:'宋体';font-size:10.5pt;">的硬盘（类似于</span><span
        style="font-family:'Calibri';font-size:10.5pt;">hda, hdb, hdc </span><span
        style="font-family:'宋体';font-size:10.5pt;">等）最多可以创建</span><span style="font-family:'Calibri';font-size:10.5pt;">10</span><span
        style="font-family:'宋体';font-size:10.5pt;">个（</span><span style="font-family:'Calibri';font-size:10.5pt;">hdb5-hdb15</span><span
        style="font-family:'宋体';font-size:10.5pt;">），这是笔者试验出来的结果</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span
        style="font-family:'宋体';font-size:10.5pt;">有的资料说</span><span style="font-family:'Calibri';font-size:10.5pt;">linux</span><span
        style="font-family:'宋体';font-size:10.5pt;">下的逻辑分区是没有限制的，也有的说最大可以到</span><span
        style="font-family:'Calibri';font-size:10.5pt;">64</span><span style="font-family:'宋体';font-size:10.5pt;">，至于对不对，需要你去近一步考察了，我们没有必要多么深入的研究这个问题，也没有什么意义</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span></p>
<p style="text-align: justify;text-indent: 21pt;"><span
        style="font-family:'宋体';font-size:10.5pt;">通过以上操作，相信你也学会了用</span><span
        style="font-family:'Calibri';font-size:10.5pt;">fdisk </span><span style="font-family:'宋体';font-size:10.5pt;">来分区了吧</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span style="font-family:'宋体';font-size:10.5pt;">值得提出的是，不要闲着没事分区玩儿，这操作的危险性是很高的，一不留神就把你服务器上的数据全部给分没有了</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span style="font-family:'宋体';font-size:10.5pt;">如果有分区的操作，那么请保持百分之二百的细心，切记切记！</span>
</p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">	</span><span
        style="font-family:'Calibri';font-size:10.5pt;"><b>mkfs.ext2 / mkfs.ext3 /mke2fs </b></span><span
        style="font-family:'宋体';font-size:10.5pt;"><b>格式化</b></span><span
        style="font-family:'Calibri';font-size:10.5pt;"><b>linux</b></span><span
        style="font-family:'宋体';font-size:10.5pt;"><b>硬盘分区</b></span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">	</span><span
        style="font-family:'宋体';font-size:10.5pt;">当用</span><span
        style="font-family:'Calibri';font-size:10.5pt;">man</span><span style="font-family:'宋体';font-size:10.5pt;">查询这三个命令的帮助文档时，你会发现我们看到了同一个帮助文档，这说明三个命令是一样的</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span
        style="font-family:'宋体';font-size:10.5pt;">常用的选项有：</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">	-b</span><span
        style="font-family:'宋体';font-size:10.5pt;">：分区时设定每个数据区块占用空间大小，目前支持</span><span
        style="font-family:'Calibri';font-size:10.5pt;">1024, 2048 </span><span
        style="font-family:'宋体';font-size:10.5pt;">以及</span><span style="font-family:'Calibri';font-size:10.5pt;">4096 bytes</span><span
        style="font-family:'宋体';font-size:10.5pt;">每个块</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">	-i</span><span
        style="font-family:'宋体';font-size:10.5pt;">：设定</span><span
        style="font-family:'Calibri';font-size:10.5pt;">inode</span><span
        style="font-family:'宋体';font-size:10.5pt;">大小</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">	-N</span><span
        style="font-family:'宋体';font-size:10.5pt;">：设定</span><span
        style="font-family:'Calibri';font-size:10.5pt;">inode</span><span style="font-family:'宋体';font-size:10.5pt;">数量，有时使用默认的inode数不够用，所以要自定设定inode数量。</span>
</p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">	-c</span><span
        style="font-family:'宋体';font-size:10.5pt;">：在格式化前先检测一下磁盘是否有问题，加上这个选项后会非常慢</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">	-L</span><span
        style="font-family:'宋体';font-size:10.5pt;">：预设该分区的标签</span><span
        style="font-family:'Calibri';font-size:10.5pt;">label</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">	-j</span><span
        style="font-family:'宋体';font-size:10.5pt;">：建立</span><span
        style="font-family:'Calibri';font-size:10.5pt;">ext3</span><span style="font-family:'宋体';font-size:10.5pt;">格式的分区，如果使用</span><span
        style="font-family:'Calibri';font-size:10.5pt;">mkfs.ext3 </span><span
        style="font-family:'宋体';font-size:10.5pt;">就不用加这个选项了</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;"><img src="8_90.png"></span></p>
<p style="text-align: justify;"><span style="font-family:'宋体';font-size:10.5pt;">不加任何选项，直接格式化</span><span
        style="font-family:'Calibri';font-size:10.5pt;">/dev/hdb1 </span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;"><img src="8_91.png"></span></p>
<p style="text-align: justify;"><span style="font-family:'宋体';font-size:10.5pt;">上例中更改了</span><span
        style="font-family:'Calibri';font-size:10.5pt;">block size</span><span
        style="font-family:'宋体';font-size:10.5pt;">为</span><span
        style="font-family:'Calibri';font-size:10.5pt;">4096 </span><span
        style="font-family:'宋体';font-size:10.5pt;">默认是</span><span
        style="font-family:'Calibri';font-size:10.5pt;">1024</span><span
        style="font-family:'宋体';font-size:10.5pt;">，而</span><span style="font-family:'Calibri';font-size:10.5pt;">inode大小</span><span
        style="font-family:'宋体';font-size:10.5pt;">设定为</span><span
        style="font-family:'Calibri';font-size:10.5pt;">4096。</span></p>
<p style="text-align: justify;"><span style="font-family:'宋体';font-size:10.5pt;">下面的例子分区时自定义分区的</span><span
        style="font-family:'Calibri';font-size:10.5pt;">label</span><span style="font-family:'宋体';font-size:10.5pt;">（标签）名</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;"><img src="8_92.png"></span></p>
<p style="text-align: justify;text-indent: 21pt;"><span style="font-family:'Calibri';font-size:10.5pt;"><b>e2label  </b></span><span
        style="font-family:'宋体';font-size:10.5pt;"><b>用来查看或者修改分区的标签（</b></span><span
        style="font-family:'Calibri';font-size:10.5pt;"><b>label</b></span><span
        style="font-family:'宋体';font-size:10.5pt;"><b>）</b></span></p>
<p style="text-align: justify;text-indent: 21pt;"><span style="font-family:'宋体';font-size:10.5pt;">这个命令很简单，后边直接跟分区编号，即可查看该分区的</span><span
        style="font-family:'Calibri';font-size:10.5pt;">label</span><span style="font-family:'宋体';font-size:10.5pt;">，当想要修改标签名时，分区编号后边跟想要的标签名即可</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;"><img src="8_93.png"></span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">	</span><span
        style="font-family:'Calibri';font-size:10.5pt;"><b>fsck </b></span><span
        style="font-family:'宋体';font-size:10.5pt;"><b>检查硬盘有没有坏道</b></span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">	</span><span
        style="font-family:'宋体';font-size:10.5pt;">语法：</span><span style="font-family:'Calibri';font-size:10.5pt;"> fsck [-Aar] [</span><span
        style="font-family:'宋体';font-size:10.5pt;">分区</span><span
        style="font-family:'Calibri';font-size:10.5pt;">]</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">	-A </span><span
        style="font-family:'宋体';font-size:10.5pt;">：加该参数时，后不需要跟分区名作为参数</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span
        style="font-family:'宋体';font-size:10.5pt;">它会自动检查</span><span style="font-family:'Calibri';font-size:10.5pt;">/etc/fstab </span><span
        style="font-family:'宋体';font-size:10.5pt;">文件下的所有分区（开机过程中就会执行一次该操作）；</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">	-a </span><span
        style="font-family:'宋体';font-size:10.5pt;">：自动修复检查到有问题的分区；</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">	-r </span><span
        style="font-family:'宋体';font-size:10.5pt;">：当检查到有坏道的分区时会让用户决定是否修复</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;"><img src="8_94.png"></span></p>
<p style="text-align: justify;"><span style="font-family:'宋体';font-size:10.5pt;">当你使用</span><span
        style="font-family:'Calibri';font-size:10.5pt;">fsck</span><span style="font-family:'宋体';font-size:10.5pt;">检查磁盘有无坏道时，会提示用户</span><span
        style="font-family:'Calibri';font-size:10.5pt;">“</span><span style="font-family:'宋体';font-size:10.5pt;">跑这个任务可能会导致某些挂载的文件系统损坏</span><span
        style="font-family:'Calibri';font-size:10.5pt;">”</span><span style="font-family:'宋体';font-size:10.5pt;">，所以这个命令不要轻易运行</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span style="font-family:'宋体';font-size:10.5pt;">否则真的遇到问题，系统甚至都不能启动了</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;"><img src="8_95.png"></span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;"><b>【</b></span><span
        style="font-family:'宋体';font-size:10.5pt;"><b>挂载</b></span><span
        style="font-family:'Calibri';font-size:10.5pt;"><b>/</b></span><span style="font-family:'宋体';font-size:10.5pt;"><b>卸载磁盘</b></span><span
        style="font-family:'Calibri';font-size:10.5pt;"><b>】</b></span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">	</span><span
        style="font-family:'宋体';font-size:10.5pt;">在上面的内容中讲到了磁盘的分区和格式化，那么格式化完了后，如何去用它呢？这就涉及到了挂载这块磁盘</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span style="font-family:'宋体';font-size:10.5pt;">格式化后的磁盘其实是一个块设备文件，类型为</span><span
        style="font-family:'Calibri';font-size:10.5pt;">b</span><span style="font-family:'宋体';font-size:10.5pt;">，也许你会想，既然这个块文件就是那个分区，那么直接在那个文件中写数据不就写到了那个分区中么？当然不行</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">	</span><span
        style="font-family:'宋体';font-size:10.5pt;">在挂载某个分区前需要先建立一个挂载点，这个挂载点是以目录的形式出现的</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span style="font-family:'宋体';font-size:10.5pt;">一旦把某一个分区挂载到了这个挂载点（目录）下，那么再往这个目录写数据使，则都会写到该分区中</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span style="font-family:'宋体';font-size:10.5pt;">这就需要你注意一下，在挂载该分区前，挂载点（目录）下必须是个空目录</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span style="font-family:'宋体';font-size:10.5pt;">其实目录不为空并不影响所挂载分区的使用，但是一旦挂载上了，那么该目录下以前的东西就不能看到了</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span style="font-family:'宋体';font-size:10.5pt;">只有卸载掉该分区后才能看到</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;"><b>mount </b></span><span
        style="font-family:'宋体';font-size:10.5pt;"><b>挂载设备</b></span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;"><img src="8_96.png"></span></p>
<p style="text-align: justify;"><span style="font-family:'宋体';font-size:10.5pt;">先建立</span><span
        style="font-family:'Calibri';font-size:10.5pt;">/test1  /test2 </span><span
        style="font-family:'宋体';font-size:10.5pt;">目录，然后在</span><span style="font-family:'Calibri';font-size:10.5pt;">/test1</span><span
        style="font-family:'宋体';font-size:10.5pt;">目录下建立一个</span><span style="font-family:'Calibri';font-size:10.5pt;">1.txt</span><span
        style="font-family:'宋体';font-size:10.5pt;">文件</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;"><img src="8_97.png"></span></p>
<p style="text-align: justify;"><span style="font-family:'宋体';font-size:10.5pt;">把</span><span
        style="font-family:'Calibri';font-size:10.5pt;">/dev/hdb1</span><span
        style="font-family:'宋体';font-size:10.5pt;">分区挂载到</span><span style="font-family:'Calibri';font-size:10.5pt;">/test1</span><span
        style="font-family:'宋体';font-size:10.5pt;">目录，然后再查看</span><span style="font-family:'Calibri';font-size:10.5pt;">/test1</span><span
        style="font-family:'宋体';font-size:10.5pt;">目录发下，</span><span style="font-family:'Calibri';font-size:10.5pt;">1.txt</span><span
        style="font-family:'宋体';font-size:10.5pt;">不存在了</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span
        style="font-family:'宋体';font-size:10.5pt;">此时往</span><span style="font-family:'Calibri';font-size:10.5pt;">/test1</span><span
        style="font-family:'宋体';font-size:10.5pt;">目录下写数据，则会写到</span><span
        style="font-family:'Calibri';font-size:10.5pt;">/dev/hdb1</span><span
        style="font-family:'宋体';font-size:10.5pt;">分区中</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span
        style="font-family:'宋体';font-size:10.5pt;">在讲</span><span
        style="font-family:'Calibri';font-size:10.5pt;">mount</span><span
        style="font-family:'宋体';font-size:10.5pt;">的</span><span
        style="font-family:'Calibri';font-size:10.5pt;">-a</span><span style="font-family:'宋体';font-size:10.5pt;">选项时，我们有必要先了解一下这个文件</span><span
        style="font-family:'Calibri';font-size:10.5pt;"> /etc/fstab</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;"><img src="8_98.png"></span></p>
<p style="text-align: justify;"><span style="font-family:'宋体';font-size:10.5pt;">这个文件是系统启动时，需要挂载的各个分区</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span style="font-family:'宋体';font-size:10.5pt;">第一列就是分区的</span><span
        style="font-family:'Calibri';font-size:10.5pt;">label</span><span style="font-family:'宋体';font-size:10.5pt;">；第二列是挂载点；第三列是分区的格式；第四列则是</span><span
        style="font-family:'Calibri';font-size:10.5pt;">mount</span><span style="font-family:'宋体';font-size:10.5pt;">的一些挂载参数，等下会详细介绍一下有哪些参数，一般情况下，直接写</span><span
        style="font-family:'Calibri';font-size:10.5pt;">defaults</span><span style="font-family:'宋体';font-size:10.5pt;">即可；第五列的数字表示是否被</span><span
        style="font-family:'Calibri';font-size:10.5pt;">dump</span><span style="font-family:'宋体';font-size:10.5pt;">备份，是的话这里就是</span><span
        style="font-family:'Calibri';font-size:10.5pt;">1</span><span
        style="font-family:'宋体';font-size:10.5pt;">，否则就是</span><span
        style="font-family:'Calibri';font-size:10.5pt;">0</span><span style="font-family:'宋体';font-size:10.5pt;">；第六列是开机时是否自检磁盘，就是刚才讲过的那个</span><span
        style="font-family:'Calibri';font-size:10.5pt;">fsck</span><span
        style="font-family:'宋体';font-size:10.5pt;">检测</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。1</span><span
        style="font-family:'宋体';font-size:10.5pt;">，</span><span
        style="font-family:'Calibri';font-size:10.5pt;">2</span><span
        style="font-family:'宋体';font-size:10.5pt;">都表示检测，</span><span
        style="font-family:'Calibri';font-size:10.5pt;">0</span><span
        style="font-family:'宋体';font-size:10.5pt;">表示不检测，在</span><span style="font-family:'Calibri';font-size:10.5pt;">Redhat</span><span
        style="font-family:'宋体';font-size:10.5pt;">中，这个</span><span
        style="font-family:'Calibri';font-size:10.5pt;">1</span><span
        style="font-family:'宋体';font-size:10.5pt;">，</span><span
        style="font-family:'Calibri';font-size:10.5pt;">2</span><span
        style="font-family:'宋体';font-size:10.5pt;">还有个说法，</span><span
        style="font-family:'Calibri';font-size:10.5pt;">/ </span><span
        style="font-family:'宋体';font-size:10.5pt;">分区必须设为</span><span
        style="font-family:'Calibri';font-size:10.5pt;">1</span><span
        style="font-family:'宋体';font-size:10.5pt;">，而且整个</span><span style="font-family:'Calibri';font-size:10.5pt;">fstab</span><span
        style="font-family:'宋体';font-size:10.5pt;">中只允许出现一个</span><span style="font-family:'Calibri';font-size:10.5pt;">1</span><span
        style="font-family:'宋体';font-size:10.5pt;">，这里有一个优先级的说法</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。1</span><span
        style="font-family:'宋体';font-size:10.5pt;">比</span><span
        style="font-family:'Calibri';font-size:10.5pt;">2</span><span style="font-family:'宋体';font-size:10.5pt;">优先级高，所以先检测</span><span
        style="font-family:'Calibri';font-size:10.5pt;">1</span><span
        style="font-family:'宋体';font-size:10.5pt;">，然后再检测</span><span
        style="font-family:'Calibri';font-size:10.5pt;">2</span><span style="font-family:'宋体';font-size:10.5pt;">，如果有多个分区需要开机检测那么都设置成</span><span
        style="font-family:'Calibri';font-size:10.5pt;">2</span><span
        style="font-family:'宋体';font-size:10.5pt;">吧，</span><span
        style="font-family:'Calibri';font-size:10.5pt;">1</span><span style="font-family:'宋体';font-size:10.5pt;">检测完了后会同时去检测</span><span
        style="font-family:'Calibri';font-size:10.5pt;">2。</span><span style="font-family:'宋体';font-size:10.5pt;">下面该说说第四列中常用到的参数了</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">async/sync </span><span
        style="font-family:'宋体';font-size:10.5pt;">：</span><span
        style="font-family:'Calibri';font-size:10.5pt;">async</span><span style="font-family:'宋体';font-size:10.5pt;">表示和磁盘和内存不同步，系统每隔一段时间把内存数据写入磁盘中，而</span><span
        style="font-family:'Calibri';font-size:10.5pt;">sync</span><span style="font-family:'宋体';font-size:10.5pt;">则会时时同步内存和磁盘中数据；</span>
</p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">auto/noauto </span><span
        style="font-family:'宋体';font-size:10.5pt;">：开机自动挂载</span><span
        style="font-family:'Calibri';font-size:10.5pt;">/</span><span
        style="font-family:'宋体';font-size:10.5pt;">不自动挂载；</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">default</span><span
        style="font-family:'宋体';font-size:10.5pt;">：按照大多数永久文件系统的缺省值设置挂载定义，它包含了</span><span
        style="font-family:'Calibri';font-size:10.5pt;">rw, suid, dev, exec, auto, nouser,async  </span><span
        style="font-family:'宋体';font-size:10.5pt;">；</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">ro</span><span
        style="font-family:'宋体';font-size:10.5pt;">：按只读权限挂载</span><span
        style="font-family:'Calibri';font-size:10.5pt;"> </span><span
        style="font-family:'宋体';font-size:10.5pt;">；</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">rw</span><span
        style="font-family:'宋体';font-size:10.5pt;">：按可读可写权限挂载</span><span
        style="font-family:'Calibri';font-size:10.5pt;"> </span><span
        style="font-family:'宋体';font-size:10.5pt;">；</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">exec/noexec </span><span
        style="font-family:'宋体';font-size:10.5pt;">：允许</span><span
        style="font-family:'Calibri';font-size:10.5pt;">/</span><span style="font-family:'宋体';font-size:10.5pt;">不允许可执行文件执行，但千万不要把根分区挂载为</span><span
        style="font-family:'Calibri';font-size:10.5pt;">noexec</span><span style="font-family:'宋体';font-size:10.5pt;">，那就无法使用系统了，连</span><span
        style="font-family:'Calibri';font-size:10.5pt;">mount</span><span style="font-family:'宋体';font-size:10.5pt;">命令都无法使用了，这时只有重新做系统了；</span>
</p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">user/nouser </span><span
        style="font-family:'宋体';font-size:10.5pt;">：允许</span><span
        style="font-family:'Calibri';font-size:10.5pt;">/</span><span
        style="font-family:'宋体';font-size:10.5pt;">不允许</span><span
        style="font-family:'Calibri';font-size:10.5pt;">root</span><span style="font-family:'宋体';font-size:10.5pt;">外的其他用户挂载分区，为了安全考虑，请用</span><span
        style="font-family:'Calibri';font-size:10.5pt;">nouser </span><span
        style="font-family:'宋体';font-size:10.5pt;">；</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">suid/nosuid </span><span
        style="font-family:'宋体';font-size:10.5pt;">：允许</span><span
        style="font-family:'Calibri';font-size:10.5pt;">/</span><span
        style="font-family:'宋体';font-size:10.5pt;">不允许分区有</span><span style="font-family:'Calibri';font-size:10.5pt;">suid</span><span
        style="font-family:'宋体';font-size:10.5pt;">属性，一般设置</span><span style="font-family:'Calibri';font-size:10.5pt;">nosuid </span><span
        style="font-family:'宋体';font-size:10.5pt;">；</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">usrquota </span><span
        style="font-family:'宋体';font-size:10.5pt;">：启动使用者磁盘配额模式，磁盘配额相关内容在后续章节会做介绍；</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">grquota </span><span
        style="font-family:'宋体';font-size:10.5pt;">：启动群组磁盘配额模式；</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">	</span><span
        style="font-family:'宋体';font-size:10.5pt;">学完这个</span><span style="font-family:'Calibri';font-size:10.5pt;">/etc/fstab</span><span
        style="font-family:'宋体';font-size:10.5pt;">后，我们就可以自己修改这个文件，增加一行来挂载新增分区</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span style="font-family:'宋体';font-size:10.5pt;">例如，笔者增加了这样一行</span>
</p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">	/dev/hdb1	/test1	ext3		defaults		0  0</span>
</p>
<p style="text-align: justify;"><span style="font-family:'宋体';font-size:10.5pt;">那么系统再重启时就会挂载这个分区了</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">	</span><span
        style="font-family:'宋体';font-size:10.5pt;">讲完了</span><span style="font-family:'Calibri';font-size:10.5pt;">/etc/fstab </span><span
        style="font-family:'宋体';font-size:10.5pt;">我们继续回来讲这个</span><span
        style="font-family:'Calibri';font-size:10.5pt;">mount</span><span
        style="font-family:'宋体';font-size:10.5pt;">，</span><span
        style="font-family:'Calibri';font-size:10.5pt;">mout -a </span><span style="font-family:'宋体';font-size:10.5pt;">如果运行了这个命令，则会把</span><span
        style="font-family:'Calibri';font-size:10.5pt;">/etc/fstab</span><span
        style="font-family:'宋体';font-size:10.5pt;">中出现的所有磁盘分区挂载上</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span
        style="font-family:'宋体';font-size:10.5pt;">所以当你在</span><span style="font-family:'Calibri';font-size:10.5pt;">/etc/fstab</span><span
        style="font-family:'宋体';font-size:10.5pt;">文件中增加一行后，你完全可以直接运行</span><span
        style="font-family:'Calibri';font-size:10.5pt;">mount -a </span><span
        style="font-family:'宋体';font-size:10.5pt;">来挂载你增加的那行，这样就不用重启啦</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span></p>
<p style="text-align: justify;text-indent: 21pt;"><span style="font-family:'宋体';font-size:10.5pt;">你可以使用</span><span
        style="font-family:'Calibri';font-size:10.5pt;">mount -o </span><span
        style="font-family:'宋体';font-size:10.5pt;">选项来重新挂载一个分区，并同时指定你想要的选项（即上边介绍</span><span
        style="font-family:'Calibri';font-size:10.5pt;">fstab</span><span style="font-family:'宋体';font-size:10.5pt;">第六列中那些）</span>
</p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;"><img src="8_99.png"></span></p>
<p style="text-align: justify;"><span style="font-family:'宋体';font-size:10.5pt;">看到了吧，使用了</span><span
        style="font-family:'Calibri';font-size:10.5pt;">ro</span><span style="font-family:'宋体';font-size:10.5pt;">选项，则不能新建文件了</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;"><img src="8_100.png"></span></p>
<p style="text-align: justify;"><span
        style="font-family:'宋体';font-size:10.5pt;">再重新挂载一次就恢复正常了，如果不加任何其他选项，则就是</span><span
        style="font-family:'Calibri';font-size:10.5pt;">defaults。</span></p>
<p style="text-align: justify;text-indent: 21pt;"><span style="font-family:'宋体';font-size:10.5pt;">笔者在日常的运维工作中遇到过这样的情况，一台服务器上新装了亮块磁盘，磁盘</span><span
        style="font-family:'Calibri';font-size:10.5pt;">a</span><span style="font-family:'宋体';font-size:10.5pt;">（在服务器上显示为</span><span
        style="font-family:'Calibri';font-size:10.5pt;">sdc</span><span
        style="font-family:'宋体';font-size:10.5pt;">）和磁盘</span><span
        style="font-family:'Calibri';font-size:10.5pt;">b</span><span style="font-family:'宋体';font-size:10.5pt;">（在服务器上显示为</span><span
        style="font-family:'Calibri';font-size:10.5pt;">sdd</span><span style="font-family:'宋体';font-size:10.5pt;">），有一次把这两块磁盘都拔掉了，然后再重新插上，重启机器，结果磁盘编号调换了，</span><span
        style="font-family:'Calibri';font-size:10.5pt;">a</span><span
        style="font-family:'宋体';font-size:10.5pt;">变成了</span><span
        style="font-family:'Calibri';font-size:10.5pt;">sdd</span><span
        style="font-family:'宋体';font-size:10.5pt;">，</span><span
        style="font-family:'Calibri';font-size:10.5pt;">b</span><span
        style="font-family:'宋体';font-size:10.5pt;">变成了</span><span
        style="font-family:'Calibri';font-size:10.5pt;">sdc</span><span style="font-family:'宋体';font-size:10.5pt;">（这是因为把磁盘插错了插槽），问题来了</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span style="font-family:'宋体';font-size:10.5pt;">通过上边的学习，你挂载磁盘是通过</span><span
        style="font-family:'Calibri';font-size:10.5pt;">/dev/hdb1 </span><span
        style="font-family:'宋体';font-size:10.5pt;">这样的分区名字来挂载的，如果先前加入到了</span><span
        style="font-family:'Calibri';font-size:10.5pt;">/etc/fstab </span><span
        style="font-family:'宋体';font-size:10.5pt;">中，结果系统启动后则会挂载错分区</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span style="font-family:'宋体';font-size:10.5pt;">那么怎么样避免这样的情况发生？</span>
</p>
<p style="text-align: justify;text-indent: 21pt;"><span
        style="font-family:'Calibri';font-size:10.5pt;"><b>blkid </b></span><span
        style="font-family:'Calibri';font-size:10.5pt;"> </span><span style="font-family:'宋体';font-size:10.5pt;">这个命令是用来显示磁盘分区</span><span
        style="font-family:'Calibri';font-size:10.5pt;">uuid</span><span
        style="font-family:'宋体';font-size:10.5pt;">的，</span><span
        style="font-family:'Calibri';font-size:10.5pt;">uuid</span><span style="font-family:'宋体';font-size:10.5pt;">其实就是一大串字符，在</span><span
        style="font-family:'Calibri';font-size:10.5pt;">linux</span><span style="font-family:'宋体';font-size:10.5pt;">系统中每一个分区都会有唯一的一个</span><span
        style="font-family:'Calibri';font-size:10.5pt;">uuid。</span><span style="font-family:'宋体';font-size:10.5pt;">说到这，聪明的你想到了吧，没有错，我们就用这唯一的</span><span
        style="font-family:'Calibri';font-size:10.5pt;">uuid</span><span style="font-family:'宋体';font-size:10.5pt;">来挂载磁盘分区</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;"><img src="8_101.png"></span></p>
<p style="text-align: justify;"><span style="font-family:'宋体';font-size:10.5pt;">这个命令笔者只是用来显示</span><span
        style="font-family:'Calibri';font-size:10.5pt;">uuid</span><span style="font-family:'宋体';font-size:10.5pt;">，没有其他用途所以不做详细介绍，当然你也可以在命令后边跟某一个分区，只显示该分区的</span><span
        style="font-family:'Calibri';font-size:10.5pt;">uuid。</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;"><img src="8_102.png"></span></p>
<p style="text-align: justify;"><span style="font-family:'宋体';font-size:10.5pt;">看到了吧，其实是很好用的</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span style="font-family:'宋体';font-size:10.5pt;">那么怎么让它也开机启动？很简单，把刚才敲的</span><span
        style="font-family:'Calibri';font-size:10.5pt;">mount </span><span style="font-family:'宋体';font-size:10.5pt;">磁盘的命令直接写到</span><span
        style="font-family:'Calibri';font-size:10.5pt;"> /etc/rc.d/rc.local </span><span
        style="font-family:'宋体';font-size:10.5pt;">文件即可</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span style="font-family:'宋体';font-size:10.5pt;">对了，笔者到现在还没有给你讲过这个</span><span
        style="font-family:'Calibri';font-size:10.5pt;">rc.local</span><span style="font-family:'宋体';font-size:10.5pt;">文件的作用</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span style="font-family:'宋体';font-size:10.5pt;">简单点说，系统启动完后会执行这个文件中的命令</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span style="font-family:'宋体';font-size:10.5pt;">所以只要你想开机后运行什么命令统统写入到这个文件下面吧</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;"><img src="8_103.png"></span></p>
<p style="text-align: justify;"><span style="font-family:'宋体';font-size:10.5pt;">其实这个文件就是一个</span><span
        style="font-family:'Calibri';font-size:10.5pt;">shell </span><span style="font-family:'宋体';font-size:10.5pt;">脚本，以后笔者会单独用一章来介绍它</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span
        style="font-family:'宋体';font-size:10.5pt;">行开头的</span><span
        style="font-family:'Calibri';font-size:10.5pt;">”#”</span><span style="font-family:'宋体';font-size:10.5pt;">是注释的意思，代表这行在这个脚本中不生效</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span style="font-family:'宋体';font-size:10.5pt;">你想让系统开机后运行什么命令，就把什么命令写到这里面来</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span style="font-family:'宋体';font-size:10.5pt;">就比如刚才笔者挂载的那条命令</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span style="font-family:'宋体';font-size:10.5pt;">你可以这样实现：</span>
</p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;"><img src="8_104.png"></span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">	mount </span><span
        style="font-family:'宋体';font-size:10.5pt;">还有一个比较常用的选项就是</span><span
        style="font-family:'Calibri';font-size:10.5pt;">-t </span><span style="font-family:'宋体';font-size:10.5pt;">，后边指定文件系统的类型，比如挂载软盘时就需要指定</span><span
        style="font-family:'Calibri';font-size:10.5pt;"> vfat</span><span style="font-family:'宋体';font-size:10.5pt;">，而挂载光盘时就需要指定</span><span
        style="font-family:'Calibri';font-size:10.5pt;">iso9660</span><span style="font-family:'宋体';font-size:10.5pt;">，但在笔者多年来的经验，目前的系统都是智能识别所要挂载分区的系统格式类别的</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span style="font-family:'宋体';font-size:10.5pt;">也就是说，用不着你去指定，它会自动判断的</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;"><img src="8_105.png"></span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">	</span><span
        style="font-family:'Calibri';font-size:10.5pt;"><b>umount  </b></span><span
        style="font-family:'宋体';font-size:10.5pt;"><b>卸载设备</b></span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">	</span><span
        style="font-family:'宋体';font-size:10.5pt;">现在你学会了如何挂载一个设备，那么如何去卸载一个设备呢，这就要用到</span><span
        style="font-family:'Calibri';font-size:10.5pt;">umount</span><span style="font-family:'宋体';font-size:10.5pt;">了，这个命令也简单的很，后边可以跟挂载点，也可以跟分区名</span><span
        style="font-family:'Calibri';font-size:10.5pt;">(/dev/hdb1) </span></p>
<p><img src="8_106.png"></p>
<p style="text-align: justify;"><span style="font-family:'宋体';font-size:10.5pt;">有时也许你会遇到比较难卸载的设备，就像在</span><span
        style="font-family:'Calibri';font-size:10.5pt;">windows</span><span style="font-family:'宋体';font-size:10.5pt;">下无法删除</span><span
        style="font-family:'Calibri';font-size:10.5pt;">U</span><span style="font-family:'宋体';font-size:10.5pt;">盘一样，教你一个特管用的方法就是</span><span
        style="font-family:'Calibri';font-size:10.5pt;">  umount -l /dev/hdb1 </span><span
        style="font-family:'宋体';font-size:10.5pt;">，这个</span><span
        style="font-family:'Calibri';font-size:10.5pt;">-l</span><span style="font-family:'宋体';font-size:10.5pt;">选项有强制卸载的意思，你一定要记住哦，非常有用的</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;"><b>【</b></span><span
        style="font-family:'宋体';font-size:10.5pt;"><b>建立一个</b></span><span
        style="font-family:'Calibri';font-size:10.5pt;"><b>swap</b></span><span
        style="font-family:'宋体';font-size:10.5pt;"><b>文件</b></span><span
        style="font-family:'Calibri';font-size:10.5pt;"><b>】</b></span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">	</span><span
        style="font-family:'宋体';font-size:10.5pt;">从装系统时就接触过这个</span><span
        style="font-family:'Calibri';font-size:10.5pt;">swap</span><span style="font-family:'宋体';font-size:10.5pt;">了，前面也说过它类似与</span><span
        style="font-family:'Calibri';font-size:10.5pt;">windows</span><span style="font-family:'宋体';font-size:10.5pt;">的虚拟内存，分区的时候一般大小为内存的</span><span
        style="font-family:'Calibri';font-size:10.5pt;">2</span><span style="font-family:'宋体';font-size:10.5pt;">倍，如果你的内存超过</span><span
        style="font-family:'Calibri';font-size:10.5pt;">4G</span><span
        style="font-family:'宋体';font-size:10.5pt;">，那么你分</span><span
        style="font-family:'Calibri';font-size:10.5pt;">8G</span><span style="font-family:'宋体';font-size:10.5pt;">似乎是没有必要了</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span
        style="font-family:'宋体';font-size:10.5pt;">分</span><span
        style="font-family:'Calibri';font-size:10.5pt;">4G</span><span style="font-family:'宋体';font-size:10.5pt;">足够日常交换了</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span style="font-family:'宋体';font-size:10.5pt;">然而，还会有虚拟内存不够用的情况发生</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span style="font-family:'宋体';font-size:10.5pt;">如果真遇到了，莫非还要重新分一下磁盘？当然不能！那我们就增加一个虚拟的磁盘出来</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">	</span><span
        style="font-family:'宋体';font-size:10.5pt;">基本的思路就是：建立</span><span
        style="font-family:'Calibri';font-size:10.5pt;">swapfile </span><span
        style="font-family:'Wingdings';font-size:10.5pt;">&#61664;</span><span
        style="font-family:'Calibri';font-size:10.5pt;"> </span><span
        style="font-family:'宋体';font-size:10.5pt;">格式化为</span><span
        style="font-family:'Calibri';font-size:10.5pt;">swap</span><span
        style="font-family:'宋体';font-size:10.5pt;">格式</span><span
        style="font-family:'Calibri';font-size:10.5pt;"> </span><span style="font-family:'Wingdings';font-size:10.5pt;">&#61664;</span><span
        style="font-family:'Calibri';font-size:10.5pt;"> </span><span
        style="font-family:'宋体';font-size:10.5pt;">启用该虚拟磁盘</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;"><img src="8_107.png"></span></p>
<p style="text-align: justify;"><span style="font-family:'宋体';font-size:10.5pt;">利用</span><span
        style="font-family:'Calibri';font-size:10.5pt;">dd </span><span
        style="font-family:'宋体';font-size:10.5pt;">来创建一个</span><span style="font-family:'Calibri';font-size:10.5pt;">419M</span><span
        style="font-family:'宋体';font-size:10.5pt;">的文件</span><span style="font-family:'Calibri';font-size:10.5pt;">/tmp/newdisk</span><span
        style="font-family:'宋体';font-size:10.5pt;">出来，其中</span><span
        style="font-family:'Calibri';font-size:10.5pt;">if</span><span style="font-family:'宋体';font-size:10.5pt;">代表从哪个文件读，</span><span
        style="font-family:'Calibri';font-size:10.5pt;">/dev/zero</span><span
        style="font-family:'宋体';font-size:10.5pt;">是</span><span
        style="font-family:'Calibri';font-size:10.5pt;">linux</span><span style="font-family:'宋体';font-size:10.5pt;">下特有的一个</span><span
        style="font-family:'Calibri';font-size:10.5pt;">0</span><span
        style="font-family:'宋体';font-size:10.5pt;">生成器，</span><span
        style="font-family:'Calibri';font-size:10.5pt;">of</span><span style="font-family:'宋体';font-size:10.5pt;">表示输出到哪个文件，</span><span
        style="font-family:'Calibri';font-size:10.5pt;">bs</span><span
        style="font-family:'宋体';font-size:10.5pt;">即块大小，</span><span style="font-family:'Calibri';font-size:10.5pt;">count</span><span
        style="font-family:'宋体';font-size:10.5pt;">则定义有多少个块</span><span style="font-family:'Calibri';font-size:10.5pt;">。</span>
</p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;"><img src="8_108.png"></span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">mkswap </span><span
        style="font-family:'宋体';font-size:10.5pt;">这个命令是专门格式化</span><span
        style="font-family:'Calibri';font-size:10.5pt;">swap</span><span style="font-family:'宋体';font-size:10.5pt;">格式的分区的，这个命令用的时候一定要看清楚了，否则把其他分区给格式化错了就只有哭了</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;"><img src="8_109.png"></span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">free </span><span
        style="font-family:'宋体';font-size:10.5pt;">是用来查看系统内存以及虚拟内存使用情况的，</span><span
        style="font-family:'Calibri';font-size:10.5pt;">-m</span><span
        style="font-family:'宋体';font-size:10.5pt;">选项是以</span><span
        style="font-family:'Calibri';font-size:10.5pt;">M</span><span
        style="font-family:'宋体';font-size:10.5pt;">的形式查看</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span style="font-family:'宋体';font-size:10.5pt;">可以看到当前系统的</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span
        style="font-family:'宋体';font-size:10.5pt;">而</span><span
        style="font-family:'Calibri';font-size:10.5pt;">swapon </span><span style="font-family:'宋体';font-size:10.5pt;">是启用我们新建的</span><span
        style="font-family:'Calibri';font-size:10.5pt;">swap</span><span style="font-family:'宋体';font-size:10.5pt;">文件，启用后再用</span><span
        style="font-family:'Calibri';font-size:10.5pt;">free</span><span style="font-family:'宋体';font-size:10.5pt;">查看发现多了</span><span
        style="font-family:'Calibri';font-size:10.5pt;">400M。</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;"><img src="8_110.png"></span></p>
<p style="text-align: justify;"><span style="font-family:'宋体';font-size:10.5pt;">我们还可以用</span><span
        style="font-family:'Calibri';font-size:10.5pt;">swapoff </span><span style="font-family:'宋体';font-size:10.5pt;">关闭启用的</span><span
        style="font-family:'Calibri';font-size:10.5pt;">swap</span><span
        style="font-family:'宋体';font-size:10.5pt;">文件</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;"><b>【</b></span><span
        style="font-family:'宋体';font-size:10.5pt;"><b>磁盘配额</b></span><span
        style="font-family:'Calibri';font-size:10.5pt;"><b>】</b></span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">	</span><span
        style="font-family:'宋体';font-size:10.5pt;">磁盘配合其实就是给每个用户分配一定的磁盘额度，只允许他使用这个额度范围内的磁盘空间</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span
        style="font-family:'宋体';font-size:10.5pt;">在</span><span
        style="font-family:'Calibri';font-size:10.5pt;">linux</span><span style="font-family:'宋体';font-size:10.5pt;">系统中，是多用户多任务的环境，所以会有很多人共用一个磁盘的情况</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span style="font-family:'宋体';font-size:10.5pt;">针对每个用户去限定一定量的磁盘空间是有必要的，这样才显得公平</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">	</span><span
        style="font-family:'宋体';font-size:10.5pt;">在</span><span
        style="font-family:'Calibri';font-size:10.5pt;">linux</span><span style="font-family:'宋体';font-size:10.5pt;">中，用来管理磁盘配额的东西就是</span><span
        style="font-family:'Calibri';font-size:10.5pt;">quota</span><span
        style="font-family:'宋体';font-size:10.5pt;">了</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span
        style="font-family:'宋体';font-size:10.5pt;">如果你的</span><span style="font-family:'Calibri';font-size:10.5pt;">linux</span><span
        style="font-family:'宋体';font-size:10.5pt;">上没有</span><span
        style="font-family:'Calibri';font-size:10.5pt;">quota</span><span style="font-family:'宋体';font-size:10.5pt;">，则需要你安装这个软件包</span><span
        style="font-family:'Calibri';font-size:10.5pt;"> quota-3.13-5.el5.RPM </span><span
        style="font-family:'宋体';font-size:10.5pt;">（其实版本是多少无所谓了，关键是这个软件包）</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。quota</span><span style="font-family:'宋体';font-size:10.5pt;">在实际应用中是针对整个分区进行限制的</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span
        style="font-family:'宋体';font-size:10.5pt;">如果你的</span><span style="font-family:'Calibri';font-size:10.5pt;">/dev/hda3 </span><span
        style="font-family:'宋体';font-size:10.5pt;">是挂载在</span><span style="font-family:'Calibri';font-size:10.5pt;">/home </span><span
        style="font-family:'宋体';font-size:10.5pt;">目录下的，那么</span><span style="font-family:'Calibri';font-size:10.5pt;">/home </span><span
        style="font-family:'宋体';font-size:10.5pt;">所有目录都会受到限制</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">	quota </span><span
        style="font-family:'宋体';font-size:10.5pt;">这个模块主要分为</span><span style="font-family:'Calibri';font-size:10.5pt;">quota quotacheck quotaoff  quotaon quotastats edquota  setquota  warnquota repquota</span><span
        style="font-family:'宋体';font-size:10.5pt;">这几个命令，下面就分别介绍这些命令</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">	quota </span><span
        style="font-family:'宋体';font-size:10.5pt;">用来显示某个组或者某个使用者的限额</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">	</span><span
        style="font-family:'宋体';font-size:10.5pt;">语法：</span><span style="font-family:'Calibri';font-size:10.5pt;">quota  [-guvs]  [user,group]</span>
</p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">	-g </span><span
        style="font-family:'宋体';font-size:10.5pt;">：显示某个组的限额</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">	-u </span><span
        style="font-family:'宋体';font-size:10.5pt;">：显示某个用户的限额</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">	-v </span><span
        style="font-family:'宋体';font-size:10.5pt;">：显示的意思</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">	-s </span><span
        style="font-family:'宋体';font-size:10.5pt;">：选择</span><span
        style="font-family:'Calibri';font-size:10.5pt;">inod</span><span style="font-family:'宋体';font-size:10.5pt;">或硬盘空间来显示</span>
</p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">&nbsp;</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">	quotacheck </span><span
        style="font-family:'宋体';font-size:10.5pt;">用来扫描某一个磁盘的</span><span
        style="font-family:'Calibri';font-size:10.5pt;">quota</span><span
        style="font-family:'宋体';font-size:10.5pt;">空间</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">	</span><span
        style="font-family:'宋体';font-size:10.5pt;">语法：</span><span style="font-family:'Calibri';font-size:10.5pt;">quotacheck  [-auvg]  /path</span>
</p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">	-a </span><span
        style="font-family:'宋体';font-size:10.5pt;">：扫描所有已经</span><span style="font-family:'Calibri';font-size:10.5pt;">mount</span><span
        style="font-family:'宋体';font-size:10.5pt;">的具有</span><span
        style="font-family:'Calibri';font-size:10.5pt;">quota</span><span style="font-family:'宋体';font-size:10.5pt;">支持的磁盘</span>
</p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">	-u </span><span
        style="font-family:'宋体';font-size:10.5pt;">：扫描某个使用者的文件以及目录</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">	-g </span><span
        style="font-family:'宋体';font-size:10.5pt;">：扫描某个组的文件以及目录</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">	-v </span><span
        style="font-family:'宋体';font-size:10.5pt;">：显示扫描过程</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">	-m </span><span
        style="font-family:'宋体';font-size:10.5pt;">：强制进行扫描</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">&nbsp;</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">	edquota  </span><span
        style="font-family:'宋体';font-size:10.5pt;">用来编辑某个用户或者组的</span><span
        style="font-family:'Calibri';font-size:10.5pt;">quota</span><span
        style="font-family:'宋体';font-size:10.5pt;">值</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">	</span><span
        style="font-family:'宋体';font-size:10.5pt;">语法：</span><span style="font-family:'Calibri';font-size:10.5pt;">edquota  [-u user]  [-g group] [-t]</span>
</p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">		  edquota  -p user  -u user</span>
</p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">	-u </span><span
        style="font-family:'宋体';font-size:10.5pt;">：编辑某个用户的</span><span style="font-family:'Calibri';font-size:10.5pt;">quota</span>
</p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">	-g </span><span
        style="font-family:'宋体';font-size:10.5pt;">：编辑某个组的</span><span style="font-family:'Calibri';font-size:10.5pt;">quota</span>
</p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">	-t </span><span
        style="font-family:'宋体';font-size:10.5pt;">：编辑宽限时间</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">	-p </span><span
        style="font-family:'宋体';font-size:10.5pt;">：拷贝某个用户或组的</span><span
        style="font-family:'Calibri';font-size:10.5pt;">quta</span><span style="font-family:'宋体';font-size:10.5pt;">到另一个用户或组</span>
</p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">	</span><span
        style="font-family:'宋体';font-size:10.5pt;">当运行</span><span style="font-family:'Calibri';font-size:10.5pt;">edquota  -u user </span><span
        style="font-family:'宋体';font-size:10.5pt;">时，系统会打开一个文件，你会看到这个文件中有</span><span
        style="font-family:'Calibri';font-size:10.5pt;">7</span><span style="font-family:'宋体';font-size:10.5pt;">列，它们分别代表的含义是：</span>
</p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">	Filesystem </span><span
        style="font-family:'宋体';font-size:10.5pt;">：磁盘分区，如</span><span style="font-family:'Calibri';font-size:10.5pt;">/dev/hda3</span>
</p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">	blocks </span><span
        style="font-family:'宋体';font-size:10.5pt;">：当前用户在当前的</span><span
        style="font-family:'Calibri';font-size:10.5pt;">Filesystem</span><span
        style="font-family:'宋体';font-size:10.5pt;">中所占用的磁盘容量，单位是</span><span
        style="font-family:'Calibri';font-size:10.5pt;">Kb。</span><span style="font-family:'宋体';font-size:10.5pt;">该值请不要修改</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">	soft/hard </span><span
        style="font-family:'宋体';font-size:10.5pt;">：当前用户在该</span><span style="font-family:'Calibri';font-size:10.5pt;">Filesystem</span><span
        style="font-family:'宋体';font-size:10.5pt;">内的</span><span
        style="font-family:'Calibri';font-size:10.5pt;">quota</span><span
        style="font-family:'宋体';font-size:10.5pt;">值，</span><span
        style="font-family:'Calibri';font-size:10.5pt;">soft</span><span style="font-family:'宋体';font-size:10.5pt;">指的是最低限额，可以超过这个值，但必须要在宽限时间内将磁盘容量降低到这个值以下</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。hard</span><span style="font-family:'宋体';font-size:10.5pt;">指的是最高限额，即不能超过这个值</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span style="font-family:'宋体';font-size:10.5pt;">当用户的磁盘使用量高于</span><span
        style="font-family:'Calibri';font-size:10.5pt;">soft</span><span style="font-family:'宋体';font-size:10.5pt;">值时，系统会警告用户，提示其要在宽限时间内把使用空间降低到</span><span
        style="font-family:'Calibri';font-size:10.5pt;">soft</span><span
        style="font-family:'宋体';font-size:10.5pt;">值之下</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">	inodes </span><span
        style="font-family:'宋体';font-size:10.5pt;">：目前使用掉的</span><span style="font-family:'Calibri';font-size:10.5pt;">inode</span><span
        style="font-family:'宋体';font-size:10.5pt;">的状态，不用修改</span><span style="font-family:'Calibri';font-size:10.5pt;">。</span>
</p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">	</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">	quotaon </span><span
        style="font-family:'宋体';font-size:10.5pt;">启动</span><span
        style="font-family:'Calibri';font-size:10.5pt;">quta</span><span style="font-family:'宋体';font-size:10.5pt;">，在编辑好</span><span
        style="font-family:'Calibri';font-size:10.5pt;">quota</span><span style="font-family:'宋体';font-size:10.5pt;">后，需要启动才能是</span><span
        style="font-family:'Calibri';font-size:10.5pt;">quta</span><span
        style="font-family:'宋体';font-size:10.5pt;">生效</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">	</span><span
        style="font-family:'宋体';font-size:10.5pt;">语法：</span><span style="font-family:'Calibri';font-size:10.5pt;">quotaon  [-a] [-uvg  directory]</span>
</p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">	-a </span><span
        style="font-family:'宋体';font-size:10.5pt;">：全部设定的</span><span style="font-family:'Calibri';font-size:10.5pt;">quota</span><span
        style="font-family:'宋体';font-size:10.5pt;">启动</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">	-u </span><span
        style="font-family:'宋体';font-size:10.5pt;">：启动某个用户的</span><span style="font-family:'Calibri';font-size:10.5pt;">quota</span>
</p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">	-g </span><span
        style="font-family:'宋体';font-size:10.5pt;">：启动某个组的</span><span style="font-family:'Calibri';font-size:10.5pt;">quota</span>
</p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">	-s </span><span
        style="font-family:'宋体';font-size:10.5pt;">：显示相关信息</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">&nbsp;</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">	quotaoff </span><span
        style="font-family:'宋体';font-size:10.5pt;">关闭</span><span
        style="font-family:'Calibri';font-size:10.5pt;">quota</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">	</span><span
        style="font-family:'宋体';font-size:10.5pt;">该命令常用只有一种情况</span><span
        style="font-family:'Calibri';font-size:10.5pt;">  quotaoff -a </span><span
        style="font-family:'宋体';font-size:10.5pt;">关闭全部的</span><span style="font-family:'Calibri';font-size:10.5pt;">quota</span>
</p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">	</span><span
        style="font-family:'宋体';font-size:10.5pt;">以上讲了很多</span><span style="font-family:'Calibri';font-size:10.5pt;">quota</span><span
        style="font-family:'宋体';font-size:10.5pt;">的相关命令，那么接下来笔者教你如何在实践应用中去做这个磁盘配额</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span style="font-family:'宋体';font-size:10.5pt;">整个执行过程如下：</span>
</p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">	</span><span
        style="font-family:'宋体';font-size:10.5pt;">首先先确认一下，你的</span><span
        style="font-family:'Calibri';font-size:10.5pt;">/home</span><span style="font-family:'宋体';font-size:10.5pt;">目录是不是单独的挂载在一个分区下，用</span><span
        style="font-family:'Calibri';font-size:10.5pt;">df </span><span
        style="font-family:'宋体';font-size:10.5pt;">查看即可</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span style="font-family:'宋体';font-size:10.5pt;">如果不是则需要你跟我一起做</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span style="font-family:'宋体';font-size:10.5pt;">否则这一步即可省略</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;"><img src="8_111.png"></span></p>
<p style="text-align: justify;"><span style="font-family:'宋体';font-size:10.5pt;">笔者的</span><span
        style="font-family:'Calibri';font-size:10.5pt;">linux</span><span style="font-family:'宋体';font-size:10.5pt;">系统中，</span><span
        style="font-family:'Calibri';font-size:10.5pt;">/home</span><span style="font-family:'宋体';font-size:10.5pt;">并没有单独占用一个分区</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span
        style="font-family:'宋体';font-size:10.5pt;">所以需要把</span><span style="font-family:'Calibri';font-size:10.5pt;">/home</span><span
        style="font-family:'宋体';font-size:10.5pt;">目录挂载在一个单独的分区下，因为</span><span
        style="font-family:'Calibri';font-size:10.5pt;">quota</span><span style="font-family:'宋体';font-size:10.5pt;">是针对分区来限额的</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;"><img src="8_112.png"></span></p>
<p style="text-align: justify;"><span style="font-family:'宋体';font-size:10.5pt;">笔者用</span><span
        style="font-family:'Calibri';font-size:10.5pt;">fdisk -l </span><span
        style="font-family:'宋体';font-size:10.5pt;">查看目前</span><span style="font-family:'Calibri';font-size:10.5pt;">/dev/hdb </span><span
        style="font-family:'宋体';font-size:10.5pt;">磁盘有</span><span
        style="font-family:'Calibri';font-size:10.5pt;">5</span><span style="font-family:'宋体';font-size:10.5pt;">个可用分区，所以笔者打算把</span><span
        style="font-family:'Calibri';font-size:10.5pt;">/dev/hdb1</span><span
        style="font-family:'宋体';font-size:10.5pt;">挂载在</span><span
        style="font-family:'Calibri';font-size:10.5pt;">/home </span><span style="font-family:'宋体';font-size:10.5pt;">目录下</span>
</p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;"><img src="8_113.png"></span></p>
<p style="text-align: justify;"><span style="font-family:'宋体';font-size:10.5pt;">看到了吧，目前笔者的</span><span
        style="font-family:'Calibri';font-size:10.5pt;">/home</span><span style="font-family:'宋体';font-size:10.5pt;">目录已经是一个单独的分区了</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">	1</span><span
        style="font-family:'宋体';font-size:10.5pt;">）建立测试用户</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;"><img src="8_114.png"></span></p>
<p style="text-align: justify;"><span style="font-family:'宋体';font-size:10.5pt;">首先建立一个</span><span
        style="font-family:'Calibri';font-size:10.5pt;">test</span><span style="font-family:'宋体';font-size:10.5pt;">用户，则同时建立了一个</span><span
        style="font-family:'Calibri';font-size:10.5pt;">test</span><span
        style="font-family:'宋体';font-size:10.5pt;">组</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span
        style="font-family:'宋体';font-size:10.5pt;">可以在</span><span style="font-family:'Calibri';font-size:10.5pt;">/etc/passwd</span><span
        style="font-family:'宋体';font-size:10.5pt;">中有以</span><span
        style="font-family:'Calibri';font-size:10.5pt;">test</span><span style="font-family:'宋体';font-size:10.5pt;">为开头的行，其中</span><span
        style="font-family:'Calibri';font-size:10.5pt;">uid</span><span
        style="font-family:'宋体';font-size:10.5pt;">和</span><span
        style="font-family:'Calibri';font-size:10.5pt;">gid</span><span
        style="font-family:'宋体';font-size:10.5pt;">都为</span><span
        style="font-family:'Calibri';font-size:10.5pt;">500 </span><span style="font-family:'宋体';font-size:10.5pt;">，然后又建立一个</span><span
        style="font-family:'Calibri';font-size:10.5pt;">test1</span><span style="font-family:'宋体';font-size:10.5pt;">账号，使其加入</span><span
        style="font-family:'Calibri';font-size:10.5pt;">test</span><span
        style="font-family:'宋体';font-size:10.5pt;">组，查看</span><span style="font-family:'Calibri';font-size:10.5pt;">/etc/passwd</span><span
        style="font-family:'宋体';font-size:10.5pt;">文件发现</span><span
        style="font-family:'Calibri';font-size:10.5pt;">test</span><span
        style="font-family:'宋体';font-size:10.5pt;">和</span><span
        style="font-family:'Calibri';font-size:10.5pt;">test1</span><span
        style="font-family:'宋体';font-size:10.5pt;">用户的</span><span
        style="font-family:'Calibri';font-size:10.5pt;">gid</span><span
        style="font-family:'宋体';font-size:10.5pt;">都为</span><span
        style="font-family:'Calibri';font-size:10.5pt;">500。</span><span style="font-family:'宋体';font-size:10.5pt;">（也许你对</span><span
        style="font-family:'Calibri';font-size:10.5pt;">/etc/passwd</span><span
        style="font-family:'宋体';font-size:10.5pt;">文件</span><span
        style="font-family:'Calibri';font-size:10.5pt;">、</span><span style="font-family:'宋体';font-size:10.5pt;">增加一个用户以及</span><span
        style="font-family:'Calibri';font-size:10.5pt;">uid</span><span
        style="font-family:'宋体';font-size:10.5pt;">和</span><span
        style="font-family:'Calibri';font-size:10.5pt;">gid</span><span style="font-family:'宋体';font-size:10.5pt;">等概念不熟悉，没有关系，在以后的章节中会做介绍，在这里只需要你明白即可）</span>
</p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">	2</span><span
        style="font-family:'宋体';font-size:10.5pt;">）打开磁盘的</span><span style="font-family:'Calibri';font-size:10.5pt;">quota</span><span
        style="font-family:'宋体';font-size:10.5pt;">功能</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">	</span><span
        style="font-family:'宋体';font-size:10.5pt;">默认</span><span
        style="font-family:'Calibri';font-size:10.5pt;">linux</span><span style="font-family:'宋体';font-size:10.5pt;">并没有对任何分区做</span><span
        style="font-family:'Calibri';font-size:10.5pt;">quota</span><span style="font-family:'宋体';font-size:10.5pt;">的支持，所以需要我们手动打开磁盘的</span><span
        style="font-family:'Calibri';font-size:10.5pt;">quota</span><span style="font-family:'宋体';font-size:10.5pt;">功能，你是否记得，在前面内容中分析</span><span
        style="font-family:'Calibri';font-size:10.5pt;">/etc/fstab</span><span
        style="font-family:'宋体';font-size:10.5pt;">文件的第四列时讲过这个</span><span
        style="font-family:'Calibri';font-size:10.5pt;">quota</span><span
        style="font-family:'宋体';font-size:10.5pt;">选项（</span><span style="font-family:'Calibri';font-size:10.5pt;">usrquota, grpquota</span><span
        style="font-family:'宋体';font-size:10.5pt;">）</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span style="font-family:'宋体';font-size:10.5pt;">没错，要想打开这个磁盘的</span><span
        style="font-family:'Calibri';font-size:10.5pt;">quota</span><span style="font-family:'宋体';font-size:10.5pt;">支持就是需要修改这个第四列的</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span
        style="font-family:'宋体';font-size:10.5pt;">用</span><span
        style="font-family:'Calibri';font-size:10.5pt;">vim</span><span
        style="font-family:'宋体';font-size:10.5pt;">编辑</span><span style="font-family:'Calibri';font-size:10.5pt;">/etc/fstab </span><span
        style="font-family:'宋体';font-size:10.5pt;">加入一行，如下图：</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;"><img src="8_115.png"></span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">vim</span><span
        style="font-family:'宋体';font-size:10.5pt;">命令将会在后续章节详细介绍，前面介绍过如何进入编辑模式以及如何保存文件</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span
        style="font-family:'宋体';font-size:10.5pt;">如果你的</span><span style="font-family:'Calibri';font-size:10.5pt;">linux</span><span
        style="font-family:'宋体';font-size:10.5pt;">系统已经有</span><span style="font-family:'Calibri';font-size:10.5pt;">/home</span><span
        style="font-family:'宋体';font-size:10.5pt;">这一行，那么直接修改第四列，加上</span><span
        style="font-family:'Calibri';font-size:10.5pt;">usrquota,grpguota</span><span
        style="font-family:'宋体';font-size:10.5pt;">（中间没有空格）</span><span style="font-family:'Calibri';font-size:10.5pt;">。</span><span
        style="font-family:'宋体';font-size:10.5pt;">接下来需要重新挂载</span><span
        style="font-family:'Calibri';font-size:10.5pt;">/home。</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;"><img src="8_116.png"></span></p>
<p style="text-align: justify;"><span style="font-family:'宋体';font-size:10.5pt;">另外你也可以这样实现重新挂载</span><span
        style="font-family:'Calibri';font-size:10.5pt;">/home</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;"><img src="8_117.png"></span></p>
<p style="text-align: justify;"><span style="font-family:'宋体';font-size:10.5pt;">如何查看是否启用了</span><span
        style="font-family:'Calibri';font-size:10.5pt;">quota</span><span
        style="font-family:'宋体';font-size:10.5pt;">呢？</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;"><img src="8_118.png"></span></p>
<p style="text-align: justify;"><span style="font-family:'宋体';font-size:10.5pt;">只要查看</span><span
        style="font-family:'Calibri';font-size:10.5pt;">/etc/mtab</span><span
        style="font-family:'宋体';font-size:10.5pt;">文件中</span><span
        style="font-family:'Calibri';font-size:10.5pt;">/home</span><span style="font-family:'宋体';font-size:10.5pt;">所在那行是否有</span><span
        style="font-family:'Calibri';font-size:10.5pt;">usrguota,grpquota</span><span
        style="font-family:'宋体';font-size:10.5pt;">即可</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span
        style="font-family:'宋体';font-size:10.5pt;">笔者的</span><span style="font-family:'Calibri';font-size:10.5pt;">/dev/hdb1</span><span
        style="font-family:'宋体';font-size:10.5pt;">现在已经支持了</span><span style="font-family:'Calibri';font-size:10.5pt;">quota</span>
</p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">	3</span><span
        style="font-family:'宋体';font-size:10.5pt;">）扫描磁盘的使用者使用状况，并产生重要的</span><span
        style="font-family:'Calibri';font-size:10.5pt;">aquota.group</span><span
        style="font-family:'宋体';font-size:10.5pt;">与</span><span style="font-family:'Calibri';font-size:10.5pt;">aquota.user</span>
</p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">	</span><span
        style="font-family:'宋体';font-size:10.5pt;">这一步就需要用到</span><span style="font-family:'Calibri';font-size:10.5pt;">quotacheck</span><span
        style="font-family:'宋体';font-size:10.5pt;">了，</span><span style="font-family:'Calibri';font-size:10.5pt;">aquota.group</span><span
        style="font-family:'宋体';font-size:10.5pt;">与</span><span style="font-family:'Calibri';font-size:10.5pt;">aqouta.user</span><span
        style="font-family:'宋体';font-size:10.5pt;">分别是组以及用户磁盘配额需要的配置文件</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span style="font-family:'宋体';font-size:10.5pt;">如果没有这两个文件，则磁盘配额是不会生效的</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;"><img src="8_119.png"></span></p>
<p style="text-align: justify;"><span style="font-family:'宋体';font-size:10.5pt;">当首次使用</span><span
        style="font-family:'Calibri';font-size:10.5pt;">quotacheck</span><span
        style="font-family:'宋体';font-size:10.5pt;">命令时，会提示</span><span style="font-family:'Calibri';font-size:10.5pt;">“cannot stat old user quota file ……”</span><span
        style="font-family:'宋体';font-size:10.5pt;">其实这是在提示你在</span><span
        style="font-family:'Calibri';font-size:10.5pt;">/home</span><span style="font-family:'宋体';font-size:10.5pt;">目录下没有</span><span
        style="font-family:'Calibri';font-size:10.5pt;">aquota.user</span><span
        style="font-family:'宋体';font-size:10.5pt;">以及</span><span style="font-family:'Calibri';font-size:10.5pt;">aquota.group</span><span
        style="font-family:'宋体';font-size:10.5pt;">两个文件</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span style="font-family:'宋体';font-size:10.5pt;">没有关系，因为以前并没有配置过磁盘配额，当然没有这两个文件了</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span
        style="font-family:'宋体';font-size:10.5pt;">当执行完</span><span style="font-family:'Calibri';font-size:10.5pt;">quotacheck</span><span
        style="font-family:'宋体';font-size:10.5pt;">命令后，会在</span><span style="font-family:'Calibri';font-size:10.5pt;">/home</span><span
        style="font-family:'宋体';font-size:10.5pt;">目录下生成这两个文件的</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">	4</span><span
        style="font-family:'宋体';font-size:10.5pt;">）启动</span><span
        style="font-family:'Calibri';font-size:10.5pt;">quota</span><span
        style="font-family:'宋体';font-size:10.5pt;">配额</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;"><img src="8_120.png"></span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">	5</span><span
        style="font-family:'宋体';font-size:10.5pt;">）编辑用户磁盘配额</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">	</span><span
        style="font-family:'宋体';font-size:10.5pt;">先来设定</span><span
        style="font-family:'Calibri';font-size:10.5pt;">test</span><span style="font-family:'宋体';font-size:10.5pt;">账户的配额，然后直接把</span><span
        style="font-family:'Calibri';font-size:10.5pt;">test</span><span style="font-family:'宋体';font-size:10.5pt;">的配额拷贝给</span><span
        style="font-family:'Calibri';font-size:10.5pt;">test1</span><span
        style="font-family:'宋体';font-size:10.5pt;">即可</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span
        style="font-family:'宋体';font-size:10.5pt;">这里就需要用到</span><span style="font-family:'Calibri';font-size:10.5pt;">edquota</span><span
        style="font-family:'宋体';font-size:10.5pt;">了</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;"><img src="8_121.png"></span></p>
<p style="text-align: justify;"><span style="font-family:'宋体';font-size:10.5pt;">讲上面内容修改为</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;"><img src="8_122.png"></span></p>
<p style="text-align: justify;"><span style="font-family:'宋体';font-size:10.5pt;">其中单位是</span><span
        style="font-family:'Calibri';font-size:10.5pt;">Kb</span><span
        style="font-family:'宋体';font-size:10.5pt;">，所以</span><span
        style="font-family:'Calibri';font-size:10.5pt;">soft </span><span style="font-family:'宋体';font-size:10.5pt;">值大约为</span><span
        style="font-family:'Calibri';font-size:10.5pt;">20Mb</span><span
        style="font-family:'宋体';font-size:10.5pt;">，</span><span
        style="font-family:'Calibri';font-size:10.5pt;">hard</span><span
        style="font-family:'宋体';font-size:10.5pt;">值为</span><span
        style="font-family:'Calibri';font-size:10.5pt;">30Mb</span><span style="font-family:'宋体';font-size:10.5pt;">，保存这个文件，保存的方式跟</span><span
        style="font-family:'Calibri';font-size:10.5pt;">vim</span><span style="font-family:'宋体';font-size:10.5pt;">一个文件的方式一样的</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;"><img src="8_123.png"></span></p>
<p style="text-align: justify;"><span style="font-family:'宋体';font-size:10.5pt;">将</span><span
        style="font-family:'Calibri';font-size:10.5pt;">test</span><span style="font-family:'宋体';font-size:10.5pt;">的配额复制给</span><span
        style="font-family:'Calibri';font-size:10.5pt;">test1。</span><span style="font-family:'宋体';font-size:10.5pt;">下面继续设定宽限时间</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;"><img src="8_124.png"></span></p>
<p style="text-align: justify;"><span style="font-family:'宋体';font-size:10.5pt;">默认是</span><span
        style="font-family:'Calibri';font-size:10.5pt;">7days </span><span style="font-family:'宋体';font-size:10.5pt;">在这里我们改为</span><span
        style="font-family:'Calibri';font-size:10.5pt;">1days。</span><span style="font-family:'宋体';font-size:10.5pt;">下面查看一下</span><span
        style="font-family:'Calibri';font-size:10.5pt;">test</span><span
        style="font-family:'宋体';font-size:10.5pt;">以及</span><span
        style="font-family:'Calibri';font-size:10.5pt;">test1</span><span style="font-family:'宋体';font-size:10.5pt;">用户的配额吧</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;"><img src="8_125.png"></span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">	6</span><span
        style="font-family:'宋体';font-size:10.5pt;">）编辑组磁盘配额</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;"><img src="8_126.png"></span></p>
<p style="text-align: justify;"><span style="font-family:'宋体';font-size:10.5pt;">设定组</span><span
        style="font-family:'Calibri';font-size:10.5pt;">test</span><span
        style="font-family:'宋体';font-size:10.5pt;">的</span><span
        style="font-family:'Calibri';font-size:10.5pt;">soft</span><span
        style="font-family:'宋体';font-size:10.5pt;">配额值为</span><span
        style="font-family:'Calibri';font-size:10.5pt;">40M</span><span
        style="font-family:'宋体';font-size:10.5pt;">，</span><span
        style="font-family:'Calibri';font-size:10.5pt;">hard</span><span
        style="font-family:'宋体';font-size:10.5pt;">值为</span><span
        style="font-family:'Calibri';font-size:10.5pt;">50M。</span><span style="font-family:'宋体';font-size:10.5pt;">下面查看组</span><span
        style="font-family:'Calibri';font-size:10.5pt;">test</span><span
        style="font-family:'宋体';font-size:10.5pt;">的配额</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;"><img src="8_127.png"></span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">	7</span><span
        style="font-family:'宋体';font-size:10.5pt;">）设定开机启动</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">	</span><span
        style="font-family:'宋体';font-size:10.5pt;">前面已经讲到启动磁盘配额的命令是</span><span
        style="font-family:'Calibri';font-size:10.5pt;">quotaon -aug </span><span
        style="font-family:'宋体';font-size:10.5pt;">，所以要想开机启动，只需将这条命令加入到</span><span
        style="font-family:'Calibri';font-size:10.5pt;"> /etc/rc.d/rc.local</span><span
        style="font-family:'宋体';font-size:10.5pt;">文件即可</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;"><img src="8_128.png"></span></p>

<p style="text-align: justify;"><span style="font-family:'宋体';font-size:10.5pt;">上一页 <a
        href="7.htm">Linux系统用户以及用户组管理</a></span></p>
<p style="text-align: justify;"><span style="font-family:'宋体';font-size:10.5pt;">下一页 <a
        href="9.htm">文本编辑工具vim</a></span></p>
<p style="text-align: justify;"><span style="font-family:'宋体';font-size:10.5pt;"><a
        href="index.htm">回到主目录</a>&nbsp;</span></p>

</body>
</html>